package com.zzxu.androiddemo01.button;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.zzxu.androiddemo01.R;
import com.zzxu.androiddemo01.utils.DateUtil;

public class ButtonLongClickActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_button_long_click);
        TextView tv_result = findViewById(R.id.tv_result1);
        Button button_long_click_single = findViewById(R.id.button_long_click_single);
        //使用匿名内部类来实现接口
        button_long_click_single.setOnLongClickListener(view -> {
            String desc = String.format("%s 您点击了按钮： %s", DateUtil.getNowTime(), ((Button) view).getText());
            tv_result.setText(desc);
            return true;
        }) ;
    }
}